package com.hopes.bizz.poll.om.vo;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.poll.common.constant.enums.PollModDictEnum;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;

/**
 * @author: ljh
 * @create: 2023/5/29
 */
@Data
@EqualsAndHashCode
public class PollRtDataVO implements Serializable {


    private static final long serialVersionUID = -3340185713613922114L;


    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "id")
    private Long id;


    // 站点类型
    @Schema(description = "站点类型")
    private String monitorType;


    // 是否报警
    @Schema(description = "是否报警")
    private Boolean alarmFlag;

    // 是否断网
    @Schema(description = "是否断网")
    private Boolean netFlag;


    /**
     * 数据类型 实时、分钟、小时、日、月、年
     */
    @Schema(description = "数据类型")
    private Integer dataType;

    /**
     * 企业
     */
    @Schema(description = "企业")
    private Long orgId;

    /**
     * 监控点视频
     */
    @Schema(description="监控点视频")
    private String videoIds;

    /**
     * 所属乡镇
     */
    private Long townId;

    /**
     * 监控点
     */
    @Schema(description = "监控点")
    private Long monitorSiteId;
    /**
     * 数据时间
     */
    @Schema(description = "数据时间")
    private Date dataTime;
    /**
     * 监测数据json对象{"w00000": {key: "w00000", val: "11.2", *** }}
     */
    @TableField(value = "data_json", typeHandler = JacksonTypeHandler.class)
    private JSONObject dataJson;

    // AQI
    private Double aqiData;

    public String getDataTimeStr() {
        return DateUtils.limitMinute(this.dataTime);
    }

    public String getMonitorSiteStr() {
        return DictResolver.getItemLabelByValue(PollModDictEnum.monitor_site, this.monitorSiteId);
    }

    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, this.getOrgId());
    }

    public String getTownIdStr() {
        return DictResolver.getItemLabelByValue(PollModDictEnum.town_info, DictResolver.getItemLabelByValue(PollModDictEnum.monitor_site_town, this.monitorSiteId));
    }
}
